import { Component, Injector, ViewEncapsulation } from '@angular/core';
import { AppComponentBase } from '@shared/common/app-component-base';
import {
    PipelineListDto,
    BatchTaskServiceProxy,
    BatchDto,
    NewSideTaskInput
} from '@shared/service-proxies/service-proxies';
import { finalize } from 'rxjs/operators';
import { appModuleAnimation } from '@shared/animations/routerTransition';

@Component({
    selector: 'rw24',
    templateUrl: './rw24.component.html',
    encapsulation: ViewEncapsulation.None,
    animations: [appModuleAnimation()]
})
export class RW24ModalComponent extends AppComponentBase {
    saving = false;

    pipe: PipelineListDto = new PipelineListDto();
    batch = new BatchDto();

    constructor(
        injector: Injector,
        private _taskServiceProxy: BatchTaskServiceProxy
    ) {
        super(injector);
    }

    load(pipe: PipelineListDto): void {
        this.pipe = pipe;

        this._taskServiceProxy.getBatch(pipe.taskId).subscribe(result => {
            this.batch = result;
        });
    }
}
